from django import forms


class LoginForm(forms.Form):
    username = forms.CharField(label="用户名",
     max_length=32, widget=forms.TextInput(attrs={"class": "input", "placeholder": "用户名/邮箱"}))
    password = forms.CharField(label="密码",
     min_length=6,
      widget=forms.PasswordInput(attrs={"class": "input", "placeholder": "密码"}))

    def clean_password(self):
        username = self.cleaned_data.get("username")
        password = self.cleaned_data.get("password")

        if username == password:
            raise forms.ValidationError("密码不能与用户名一致！")

        return password

